package com.bwie.controller;

import com.bwie.pojo.TbCommodity;
import com.bwie.service.TbUserService;
import com.bwie.utils.R;
import com.bwie.vo.LoginInfoVo;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : Yoo19
 * @description :
 * @createDate : 2025/6/26 9:18 18
 */
@RestController
@RequestMapping("/user/index")
public class IndexController {

    @Autowired
    TbUserService tbUserService;

    /**
     * 登陆方法
     * @param loginInfoVo
     * @return
     */
    @ApiOperation("登陆")
    @PostMapping("/login")
    public R login(@RequestBody LoginInfoVo loginInfoVo){
        return tbUserService.login(loginInfoVo);
    }

    /**
     * 获取商品列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getCommodityList")
    public R getCommodityList(@RequestBody PageInfoVo pageInfoVo){
        return tbUserService.getCommodityList(pageInfoVo);
    }

    /**
     * 获取我的订单
     * @return
     */
    @PostMapping("/getOrderList")
    public R getOrderList(){
        return  tbUserService.getOrderList();
    }

    @PostMapping("/addCommodity")
    public R addCommodity(@RequestBody @Validated TbCommodity tbCommodity){
        return tbUserService.addCommodity(tbCommodity);
    }
}
